#include "LinkSerialClient.h"
#include "PacketSl651.h"
#include <iostream>
#include "lib.h"
#include "IMode.h"

using namespace controller;

void test_sl651(void)
{
    PacketSl651 p;
    LinkSerialPort l;
    std::map<std::string, std::string> arg = {
        {"dev", "/dev/ttyv0"},
        //{"dev","/dev/ttyS0"},
        {"baud", "115200"}};
    
    l.open(arg);
    l.set_dump_buffer_type(true);
    // IMode::S2(&l, (PacketBase *)&p, (PacketBase *)&p, [&](LinkBase *l, PacketBase *r)
    //           { std::cout << "我用对象发送，我真的接收到了一个数据包啦" << std::endl; }, 10000);

    IMode::W(&l, &p, [&](LinkBase *l, PacketBase *p)
             {
        static int c = 0;
        std::cout << "第 " << std::to_string(c) << " 数据包"  << std::endl;
        c++; }, 10000, 5);
    l.close();
}